package sgi.client;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;

import javax.swing.JFrame;

import sgi.message.MessageLogoff;

public class SGIClientFrame extends JFrame {

	
	public SGIClientFrame()
	{
		setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter() {
			   public void windowClosing(WindowEvent evt) {
			     onExit();
			   }
			 });	
	}

	
		public void onExit() {
		  MessageLogoff msg = new MessageLogoff(SGIUserAccountMenuController.getUser().getUsername(),SGIUserAccountMenuController.getUser().getPassword());
		  try {
			SGIClientConnectionController.createConnection().handleMessageFromClientUI(msg);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		  System.exit(0);
		}
}
